<?php

    /**
 * ProcessSimpleType method
 * @param string $who name of the person we'll say hello to
 * @return string $helloText the hello  string
 */
    require_once ("lib/nusoap.php");
    require_once ("processService.php");
    
    $ns = "http://localhost:8080/RegisterServer";
    $server = new soap_server();
    
    //Configure WSDL
    $server->configureWSDL("RegisterService");
    $server->wsdl->schemaTargetNamespace = $ns;
    
 
 //=======================================================================================//
 //=======================================================================================//
   $server->register(
           'SendXmlString',
           array('table'=>'xsd:string', 'xmlstring'=>'xsd:string', 'Method'=>'xsd:string', 'ClientBit'=>'xsd:string'),
           array(),
           $ns,
           FALSE,
           'rpc',
           'encoded',
           'Get XML String from client'
           );
   $server->register(
           'GetXmlString',
           array('tablename'=>'xsd:string', 'Method'=>'xsd:string', 'ClientBit'=>'xsd:string'),
           array('return'=>'xsd:string'),
           $ns,
           FALSE,
           'rpc',
           'encoded',
           'Create string XML'
           );
   $server->register(
           'currentTime',
           array(),
           array('return'=>'xsd:string'),
           $ns,
           FALSE,
           'rpc',
           'encoded',
           'Get Current Time'
           );
 //=======================================================================================//
   function GetXmlString($tablename, $Method, $ClientBit)
   {
       $process = new processService;
       return $process->GetData($tablename, $Method, $ClientBit);
   }
   function SendXmlString($table,$xmlstring, $Method, $ClientBit)
   {
       $process = new processService;
       $process->insertData($table,$xmlstring, $Method, $ClientBit);
   }
 //=====================================================================================//
 //Lay ngay gio hien tai cua he thong
   function currentTime()
    {
        $process = new processService;
        return $process->getCurrentTime();
    }
 //=====================================================================================//
    
    
//    $clientbit = '100';
//    $table = 'Students';
//    $method = 'Update';
//    $string = "<Students><ID>A0006</ID><FullName>Nguyen Minh Van</FullName><GenderId>1</GenderId><Birthday>1989-05-18</Birthday><Career>sinh vien</Career><Email>nmvan@gmail.com</Email><Phone>978652365</Phone><Address>Thien phuoc</Address><Note>Chinh sua ngay: 11/24/2012 11:07:27 PM Boi Nhan Vien: ID: A0002, Ten: Nguyen Trung Nhat
//                - Noi dung chinh sua: Them dia chi Email
//                - 
//                Chinh sua ngay: 11/25/2012 12:36:47 AM Boi Nhan Vien: ID: A0001, Ten: Nguyen Trung Nhat
//                - Noi dung chinh sua: Them nghe nghiep
//                - 
//                Chinh sua ngay: 11/27/2012 05:35:17 PM Boi Nhan Vien: ID: A0002, Ten: Nguyen Trung Nhat
//                - Noi dung chinh sua: them dia chi
//                - 
//                </Note><NewRecord>0</NewRecord><LastUpdate>2012-11-27T17:35:17</LastUpdate><CreateDateTime>2012-11-21T09:32:18</CreateDateTime>
//                </Students>
//                <Students><ID>A0007</ID><FullName>Nguyen Minh Van</FullName><GenderId>1</GenderId><Birthday>1989-05-18</Birthday><Career>sinh vien</Career><Email>nmvan@gmail.com</Email><Phone>978652365</Phone><Address>Thien phuoc</Address><Note>Chinh sua ngay: 11/24/2012 11:07:27 PM Boi Nhan Vien: ID: A0002, Ten: Nguyen Trung Nhat
//                - Noi dung chinh sua: Them dia chi Email
//                - 
//                Chinh sua ngay: 11/25/2012 12:36:47 AM Boi Nhan Vien: ID: A0001, Ten: Nguyen Trung Nhat
//                - Noi dung chinh sua: Them nghe nghiep
//                - 
//                Chinh sua ngay: 11/27/2012 05:35:17 PM Boi Nhan Vien: ID: A0002, Ten: Nguyen Trung Nhat
//                - Noi dung chinh sua: them dia chi
//                - 
//                </Note><NewRecord>0</NewRecord><LastUpdate>2012-11-27T17:35:17</LastUpdate><CreateDateTime>2012-11-21T09:32:18</CreateDateTime>
//                </Students>";
//    SendXmlString($table, $string, $method, $clientbit);
//    $string = GetXmlString($table, $method, $clientbit);
//    echo $string;
    
    //out put return
    $HTTP_RAW_POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA'])?$GLOBALS['HTTP_RAW_POST_DATA']:'';
    $server->service($HTTP_RAW_POST_DATA);
    exit();
?>
